#! /bin/sh /usr/share/dpatch/dpatch-run
## 07_Makefile.dpatch by  <Torsten Werner <twerner@debian.org>>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad mseide-msegui-1.8~/Makefile mseide-msegui-1.8/Makefile
--- mseide-msegui-1.8~/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ mseide-msegui-1.8/Makefile	2008-10-06 22:26:16.000000000 +0200
@@ -0,0 +1,69 @@
+##########################################################################
+# Debian
+##########################################################################
+
+ifndef DEBDIR
+DEBDIR=debian
+endif
+
+# Build dir
+ifndef BUILDDIR
+BUILDDIR=build
+endif
+
+# Link Tree
+ifdef LINKISCOPY
+ifndef LINKTREE
+LINKTREE:=cp -Rfp
+endif
+else
+ifndef LINKTREE
+LINKTREE:=cp -Rfpl
+endif
+endif
+
+ifndef ECHO
+ECHO=echo
+endif
+
+ifneq ($(wildcard ${DEBDIR}/changelog),)
+
+.PHONY: debcopy deb
+
+DEBPACKAGEVERSION:=$(shell head -n 1 ${DEBDIR}/changelog | sed -e 's/mseide-msegui (\([0-9\.]\+\)-[0-9]).*/\1/')
+MSEVERSION:=$(shell grep Version VERSION.TXT | head -n 1 | sed -e 's/Version \([0-9\.]\+\)/\1/')
+DEBSRCDIR:=$(BUILDDIR)/mseide-msegui-$(MSEVERSION)
+
+debcheck:
+ifneq ($(MSEVERSION),$(DEBPACKAGEVERSION))
+	@$(ECHO) "Debian version ($(DEBPACKAGEVERSION)) is not correct, expect $(MSEVERSION)"
+	@exit 1
+endif
+
+debcopy:
+	rm -rf ${BUILDDIR}
+	install -d $(DEBSRCDIR)
+	$(LINKTREE) -t ${DEBSRCDIR} \
+		${DEBDIR} \
+		README.TXT VERSION.TXT \
+		apps docs lib patch_fpc_2_2 tools
+	find $(DEBSRCDIR) -name 'CVS*' | xargs -n1 rm -rf
+	find $(DEBSRCDIR) -name '.svn' | xargs -n1 rm -rf
+	chmod 755 $(DEBSRCDIR)/debian/rules
+
+debbuild:
+ifdef NODOCS
+	cd $(DEBSRCDIR) ; dpkg-buildpackage -us -uc -B
+else
+	cd $(DEBSRCDIR) ; dpkg-buildpackage -us -uc
+endif
+	mv -v -t . $(DEBSRCDIR)/../*.{deb,dsc,changes,tar.gz}
+
+debclean:
+	rm -rf $(DEBSRCDIR)
+	rmdir $(BUILDDIR)
+
+deb: debcheck debcopy debbuild debclean
+
+endif # changelog found
+
